<script>
	export default {
		onLaunch: function() {
			try{
				let arg = plus.runtime.arguments;
				let ua =
					uni.getStorageSync('UA') ||
					'Mozilla/5.0 (Linux; Android 7.1.2; V1923A Build/N2G47O; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/68.0.3440.70 Mobile Safari/537.36 SCRIPT/2.0';
				plus.navigator.setUserAgent(ua, false);
				this.getIntentData(arg)
			}catch(e){
				//TODO handle the exception
			}
			
			console.log('App Launch')
		},
		onShow: function() {
			try{
				plus.globalEvent.addEventListener('newintent', () => {
					let arg = plus.runtime.arguments;
					this.getIntentData(arg)
				});
			}catch(e){
				//TODO handle the exception
			}
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			getIntentData(arg) {
				if (typeof arg == 'string') {
					try {
						arg = JSON.parse(arg);
					} catch (e) {
						//TODO handle the exception
					}
				}
				if (arg.targeturl) {
					uni.navigateTo({
						url: '/pages/browser/index?url=' + arg.targeturl,
						animationType: 'fade-in'
					});
				}
				if (arg.url) {
					uni.navigateTo({
						url: '/pages/browser/index?url=' + arg.url,
						animationType: 'fade-in'
					});
				}
				if (typeof arg === 'string' && arg.length > 0) {
					uni.navigateTo({
						url: '/pages/browser/index?url=' + arg,
						animationType: 'fade-in'
					});
				}
			}
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
